using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using XLua;
using Yoozoo.Framework.Managers;

namespace Yoozoo.Gameplay.City
{
    public class StreetScoreHud : MonoBehaviour
    {
        /// <summary>
        /// 飘字内容
        /// </summary>
        public TextMeshPro ScoreText;
        
        /// <summary>
        /// 普通材质
        /// </summary>
        public Material NormalMaterial;
        /// <summary>
        /// 暴击材质
        /// </summary>
        public Material CriticalMaterial;

        /// <summary>
        /// 翻译文本
        /// </summary>
        public TextMeshPro LangText;

        public string LangId;

        private void Awake()
        {
            if (LuaManager.mainState != null)
            {
                var m_langTable = LuaManager.GetTable("L_LangUtils");
                var m_getLangTextFunc = m_langTable?.Get<LuaFunction>("getLangText");
                if (LangText)
                {
                    LangText.text = m_getLangTextFunc?.Func<int, string, string>(0, LangId);
                }
            }
        }
        
        public void SetMaterial(bool isCritical)
        {
            Material mat = null;
            if (isCritical)
            {
                mat = CriticalMaterial;
            }
            else
            {
                mat = NormalMaterial;
            }

            if (mat && ScoreText.fontMaterial != mat)
            {
                ScoreText.fontMaterial = mat;
            }
        }
        
        public void SetText(string str)
        {
            ScoreText.text = str;
        }
        
    }
}
